<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>消息管理</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/static_back/css/public.css" type="text/css" rel="stylesheet">
	<link href="${ctxStatic}/static_back/css/main.css" type="text/css" rel="stylesheet">
</head>

<body>
	<%--标题--%>
	<div class="top-section">
		<h2>实时消息</h2>
	</div>

	<div class="body-section whole-body">

		<div class="realtime-box realtime-box1">
			<div class="realtime-head">
				<span>调度请求</span>
				<a href="${ctx}/air/airRealtimeMessage?type=1" >更多 ></a>
			</div>
			<div class="realtime-body">
				<div class="realtime-body-left">
					<%--todo 缺数据--%>
					<span id="message_count_1">${vo.schedulingSum}</span>
					<em>今日次数</em>
				</div>
				<div class="realtime-body-right scroll-box">
					<ul class="info-timeline" id="message_total_1">
						<c:forEach items="${vo.schedulingList}" var="f">
							<li>
								<em><fmt:formatDate value="${f.feedbackDate}" pattern="HH:mm:ss" />&nbsp;&nbsp;${f.airWorker}：</em>
								<span>${f.airRidePoint.name}&nbsp;&nbsp;${f.title}</span>
								${f.note}
							</li>
						</c:forEach>
						<%--todo 没有数据时显示无数据提示--%>
						<c:if test="${empty vo.schedulingList}">
							<li>
								<em>暂无调度请求。</em>
							</li>
						</c:if>
					</ul>
				</div>
			</div>
		</div>

		<div class="realtime-box realtime-box2">
			<div class="realtime-head">
				<span>异常反馈</span>
				<a href="${ctx}/air/airRealtimeMessage?type=2" >更多 ></a>
			</div>
			<div class="realtime-body">
				<div class="realtime-body-left">
					<%--todo 缺数据--%>
					<span id="message_count_2">${vo.abnormalSum}</span>
					<em>今日次数</em>
				</div>
				<div class="realtime-body-right scroll-box">
					<ul class="info-timeline" id="message_total_2">
						<c:forEach items="${vo.abnormalList}" var="f">
							<li>
								<em><fmt:formatDate value="${f.feedbackDate}" pattern="HH:mm:ss" />&nbsp;&nbsp;${f.airWorker}：</em>
								<span>${f.airRidePoint.name}&nbsp;&nbsp;${f.title}</span>
								${f.note}
							</li>
						</c:forEach>
						<%--todo 没有数据时显示无数据提示--%>
						<c:if test="${empty vo.abnormalList}">
							<li>
								<em>暂无异常反馈。</em>
							</li>
						</c:if>
					</ul>
				</div>
			</div>
		</div>

		<div class="realtime-box realtime-box3">
			<div class="realtime-head">
				<span>调度操作记录</span>
				<a href="${ctx}/air/airRealtimeMessage?type=3" >更多 ></a>
			</div>
			<div class="realtime-body">
				<div class="realtime-body-left">
					<%--todo 缺数据--%>
					<span id="message_count_3">${vo.operationSum}</span>
					<em>今日次数</em>
				</div>
				<div class="realtime-body-right scroll-box">
					<ul class="info-timeline" id="message_total_3">
						<c:forEach items="${vo.operationList}" var="s">
							<li>
								<em><fmt:formatDate value="${s.feedbackDate}" pattern="HH:mm:ss" />&nbsp;&nbsp;${s.airWorker}：</em>
								${s.note}
							</li>
						</c:forEach>
						<%--todo 没有数据时显示无数据提示--%>
						<c:if test="${empty vo.operationList}">
							<li>
								<em>暂无调度操作记录。</em>
							</li>
						</c:if>
					</ul>
				</div>
			</div>
		</div>

		<div class="realtime-box realtime-box4">
			<div class="realtime-head">
				<span>信息报送</span>
				<a href="${ctx}/air/airRealtimeMessage?type=4" >更多 ></a>
			</div>
			<div class="realtime-body">
				<div class="realtime-body-left">
					<%--todo 缺数据--%>
					<span id="message_count_4">${vo.submissionSum}</span>
					<em>今日次数</em>
				</div>
				<div class="realtime-body-right scroll-box">
					<ul class="info-timeline" id="message_total_4">
						<c:forEach items="${vo.submissionList}" var="d">
							<li>
								<em><fmt:formatDate value="${d.feedbackDate}" pattern="HH:mm:ss" />&nbsp;&nbsp;${d.airWorker}：</em>
									${d.airRidePoint.name}&nbsp;&nbsp;${d.note}
							</li>
						</c:forEach>
						<%--todo 信息报送有两种类型，一种是发车记录，一种是候车记录--%>
						<%--todo 没有数据时显示无数据提示--%>
						<c:if test="${empty vo.submissionList}">
							<li>
								<em>暂无信息报送。</em>
							</li>
						</c:if>
					</ul>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
        $(function () {
            setInterval(function () {
                updateMessageTotal();
            }, 1000 * 5);
            var updateMessageTotal = function () {
                $.ajax({
                    url:'${ctx}/air/airRealtimeMessage/getMessageTotal.do',
                    type:'GET',
                    success:function (data) {
                        var vo = data.data;
                        $('#message_count_1').html(vo.schedulingSum);
                        $('#message_count_2').html(vo.abnormalSum);
                        $('#message_count_3').html(vo.operationSum);
                        $('#message_count_4').html(vo.submissionSum);
                        $('#message_total_1').empty();
                        if(vo.schedulingList&&vo.schedulingList.length>0){
                            var newHtml = '';
                            for(var a in vo.schedulingList){
                                var f = vo.schedulingList[a];
                                newHtml+= '<li>\n' +
                                    '<em>'+ f.feedbackDate.substring(11) +'&nbsp;&nbsp;'+f.airWorker+'：</em>\n' +
                                    '<span>'+f.airRidePoint.name+'&nbsp;&nbsp;'+f.title+'</span>\n' + f.note + '</li>'
                            }
                            $('#message_total_1').html(newHtml);
                        }else{
                            $('#message_total_1').html('<li> <em>暂无调度请求。</em> </li>');
                        }
                        if(vo.abnormalList&&vo.abnormalList.length>0){
                            var newHtml = '';
                            for(var a in vo.abnormalList){
                                var f = vo.abnormalList[a];
                                newHtml+= '<li>\n' +
                                    '<em>'+ f.feedbackDate.substring(11) +'&nbsp;&nbsp;'+f.airWorker+'：</em>\n' +
                                    '<span>'+f.airRidePoint.name+'&nbsp;&nbsp;'+f.title+'</span>\n' + f.note + '</li>'
                            }
                            $('#message_total_2').html(newHtml);
                        }else{
                            $('#message_total_2').html('<li> <em>暂无异常反馈。</em> </li>');
                        }
                        if(vo.operationList&&vo.operationList.length>0){
                            var newHtml = '';
                            for(var a in vo.operationList){
                                var f = vo.operationList[a];
                                newHtml+= '<li>\n' +
                                    '<em>'+ f.feedbackDate.substring(11) +'&nbsp;&nbsp;'+f.airWorker+'：</em>\n' +
//                                    '<span>'+f.airRidePoint.name+'&nbsp;&nbsp;'+f.title+'</span>\n' +
									f.note +
									'</li>'
                            }
                            $('#message_total_3').html(newHtml);
                        }else{
                            $('#message_total_3').html('<li> <em>暂无调度操作记录。</em> </li>');
                        }
                        if(vo.submissionList&&vo.submissionList.length>0){
                            var newHtml = '';
                            for(var a in vo.submissionList){
                                var f = vo.submissionList[a];
                                newHtml+= '<li>\n' +
                                    '<em>'+ f.feedbackDate.substring(11) +'&nbsp;&nbsp;'+f.airWorker+'：</em>\n' +
//                                    '<span>'+f.airRidePoint.name+'&nbsp;&nbsp;'+f.title+'</span>\n' +
									f.note +
									'</li>'
                            }
                            $('#message_total_4').html(newHtml);
                        }else{
                            $('#message_total_4').html('<li> <em>暂无信息报送。</em> </li>');
                        }
                    }
                })
            }
        })
	</script>
</body>
</html>